<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//Dth HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dth">
<html>
<head>
<title>商品列表</title>
<script type="text/javascript" src="${ctx}/resources/js/jquery.masonry.min.js"></script>
<script type="text/javascript">
$(function(){
	$("#upDownBtn").click(function(){
		if ($("#searchPanle").css("display") == "none") {
			$("#searchPanle").slideDown("slow");
			$(this).removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up");
		} else {
			$("#searchPanle").slideUp("slow");
			$(this).removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
		}
	});
});
</script>
	</head>
	<body>
	
	<div class="crumbClip"></div>
	
	<%!
	private String getSearchUrl(HttpServletRequest request, String... removes) {
		String queryString = "&" + request.getQueryString() + "&";
	for (String remove : removes) {
		int index = queryString.indexOf("&" + remove + "=");
		if (index < 0) {
			continue;
		}
		String begin = queryString.substring(0, index);
		String end = queryString.substring(index + remove.length(), queryString.length());
		end = end.substring(end.indexOf("&"));
		queryString = begin + end;
	}
	if (queryString.startsWith("&")) {
		queryString = queryString.substring(1);
	}
	if (queryString.endsWith("&")) {
		queryString = queryString.substring(0, queryString.length() - 1);
	}
	return request.getContextPath() + "/search?" + queryString;
}
%>
<%
String queryString = request.getQueryString();
if (queryString == null || "".equals(queryString)) {
	queryString = "";
} else {
	queryString += "&";
}
%>
<!--serach -->
<div id="searchPanle" class="serach-top">
	<c:if test="${not empty brand}">
	<!-- 品牌查询条件 -->
	<div class="serach-attr">
		<div class="serach-attr-left fl">
			<div class="kalit">品牌</div>
		</div>
		<div class="serach-attr-right fr">
		<ul>
			<c:forEach items="${brand}" var="b" varStatus="i">
				<c:if test="${i.index < 6}">
					<li><a href="${ctx}/search?<%= queryString %>brandId=${b.id}&brandName=${b.name}">${b.name}</a></li>
				</c:if>
			</c:forEach>
		</ul>
		</div>
	</div>
	</c:if>
	<c:if test="${not empty prs}">
	<div class="serach-attr">
		<div class="serach-attr-left fl">
			<div class="kalit">价格</div>
		</div>
		<div class="serach-attr-right fr">
		<ul>
			<c:forEach items="${prs}" var="p">
				<li><a href="${ctx}/search?<%=queryString %>priceBegin=${p.priceBegin}&priceEnd=${p.priceEnd}&priceText=${p.text}">${p.text}</a></li>
			</c:forEach>
		</ul>
		</div>
	</div>
	</c:if>
	<div class="serach-attr">
		<div class="serach-attr-left fl">
			<div class="kalit">排序</div>
		</div>
		<div class="serach-attr-right fr">
		<ul>
			<li><a href="${ctx}/search">按上架排序</a></li>
			<li><a href="${ctx}/search">按售价升序</a></li>
			<li><a href="${ctx}/search">按售价降序</a></li>
			<li><a href="${ctx}/search">按热门</a></li>
			<li><a href="${ctx}/search">按热销</a></li>
		</ul>
		</div>
	</div>
</div>
<div style="width:10px;margin:0 auto;">
	<a id="upDownBtn" href="javascript:void(0);" class="glyphicon glyphicon-chevron-up"></a>
</div>
<div class="serach-top">
	<div class="J-serach">
		<span style="margin-left: 120px;">&nbsp;</span>
		<c:if test="${search.brandId != null}">
			<a href="<%=getSearchUrl(request, "brandId", "brandName")%>">品牌:${search.brandName}&nbsp;&times;</a>
		</c:if>
		<c:if test="${search.priceBegin != null || search.priceEnd != null}">
			<a href="<%=getSearchUrl(request, "priceBegin", "priceEnd", "priceText")%>">价格:${search.priceText}&nbsp;&times;</a>
		</c:if>
	</div>
</div>
<!--serach  end-->


</body>
</html>